function HandleSheetSearch(gui, user, date, options, data) {
  this._gui = gui;
  this._user = user;
  this._date = date;
  this._options = options;
  this._data = data;
  
  this._popupBox = new ModulePopupBoxSimple();
  
  this._callbackFunc = (options && options.callbackFunc) ? options.callbackFunc : function() {};
  this._search = (options && options.search) ? options.search : null;
  if (!this._search) {
    this._search = PPublishUtils.sheetSearch();
  }

  this._photographers = this._data['photographer'].data;
  this._cultures = this._data['culture'].data;
  this._ceremonys = this._data['ceremony'].data;
  this._receptions = this._data['reception'].data;
  this._colors = this._data['color'].data;
  this._cond = this._data['cond'];

  this._createElements();
}

HandleSheetSearch.prototype._createElements = function() {
  var _self = this;
  DOMUtils.removeChildElements(this._gui.branch);
  DOMUtils.removeChildElements(this._gui.photographer);
  DOMUtils.removeChildElements(this._gui.culture);
  DOMUtils.removeChildElements(this._gui.ceremony);
  DOMUtils.removeChildElements(this._gui.reception);
  DOMUtils.removeChildElements(this._gui.weddingcolor);
  
  this._gui.customerNo.value = this._search.customerNo;
  this._gui.customerName.value = this._search.customerName;
  
  this._gui.customerNo.onchange = function(e) { _self._search.customerNo = this.value; };
  this._gui.customerNo.onkeypress = function(e) { _self._search.customerNo = this.value;
                                                  var code = DOMUtils.getEventCode(e);
                                                  if (code == 13) {
                                                    _self._callbackFunc(_self._search);
                                                  } else {
                                                    var div = document.createElement('div');
                                                    var pos1 = DOMUtils.findPos(_self._gui.customerNo);
                                                    var pos = [pos1[0] + 1, pos1[1] + 82];
                                                    var query = "SELECT DISTINCT t.customer_id as customer_id FROM pz_task as t WHERE 1 = 1 AND " + '((t.customer_id LIKE \'%' + _self._gui.customerNo.value + '%\'))' + ' AND ' + ((_self._cond) ? _self._cond : '1=1') + " ";
                                                    MiscUtils.dialog(_self._popupBox, pos, div, null, null, {pop: true});
                                                    new ModuleDialogSearchResult(document, div, 170, null, _self._user, _self._date, { item: _self._gui.customerNo, query: query, popupBox: _self._popupBox, callbackFunc: function() { _self._search.customerNo = _self._gui.customerNo.value; }}, _self._data);
                                                  }
                                                };
  
  this._gui.customerName.onchange = function(e) { _self._search.customerName = this.value; };
  this._gui.customerName.onkeypress = function(e) { _self._search.customerName = this.value;
                                                  var code = DOMUtils.getEventCode(e);
                                                  if (code == 13) {
                                                    _self._callbackFunc(_self._search);
                                                  } else {
                                                    var div = document.createElement('div');
                                                    var pos1 = DOMUtils.findPos(_self._gui.customerName);
                                                    var pos = [pos1[0] + 1, pos1[1] + 82];
                                                    var query = "SELECT DISTINCT t.bride_name, t.groom_name FROM pz_task as t WHERE 1 = 1 AND " + '((t.bride_name LIKE \'%' + _self._gui.customerName.value + '%\') OR (t.groom_name LIKE \'%' + _self._gui.customerName.value + '%\'))' + ' AND ' + ((_self._cond) ? _self._cond : '1=1') + " ";
                                                    MiscUtils.dialog(_self._popupBox, pos, div, null, null, {pop: true});
                                                    new ModuleDialogSearchResult(document, div, 170, null, _self._user, _self._date, { item: _self._gui.customerName, query: query, popupBox: _self._popupBox, callbackFunc: function() { _self._search.customerName = _self._gui.customerName.value; }}, _self._data);
                                                  }
                                                };
  
  this._gui.branch.options[this._gui.branch.options.length] = new Option('All');
  for (var i = 0, il = Branch.array().length; i < il; i++) {
    var branch = Branch.array()[i];
    option = new Option(branch);
    this._gui.branch.options[this._gui.branch.options.length] = option;
    if (option.text == this._search.branch) {
      this._gui.branch.selectedIndex = this._gui.branch.options.length - 1;
    }
  }
  this._gui.branch.onchange = function() { _self._search.branch = ((this.options[this.selectedIndex].text != 'All') ? this.options[this.selectedIndex].text : ''); };
  
  this._gui.photographer.options[this._gui.photographer.options.length] = new Option('All');
  for (var i = 0, il = this._photographers.length; i < il; i++) {
    var u = this._photographers[i];
    option = new Option(u.name + '(' + u.branch + ')');
    this._gui.photographer.options[this._gui.photographer.options.length] = option;
    if (option.text == this._search.photographer) {
      this._gui.photographer.selectedIndex = this._gui.photographer.options.length - 1;
    }
  }
  this._gui.photographer.onchange = function() { _self._search.photographer = ((this.options[this.selectedIndex].text != 'All') ? this.options[this.selectedIndex].text : ''); };
  
  this._gui.culture.options[this._gui.culture.options.length] = new Option('All');
  for (var i = 0, il = this._cultures.length; i < il; i++) {
    var culture = this._cultures[i];
    option = new Option(culture.name);
    this._gui.culture.options[this._gui.culture.options.length] = option;
    if (option.text == this._search.culture) {
      this._gui.culture.selectedIndex = this._gui.culture.options.length - 1;
    }
  }
  this._gui.culture.onchange = function() { _self._search.culture = ((this.options[this.selectedIndex].text != 'All') ? this.options[this.selectedIndex].text : ''); };
  
  this._gui.ceremony.options[this._gui.ceremony.options.length] = new Option('All');
  for (var i = 0, il = this._ceremonys.length; i < il; i++) {
    var ceremony = this._ceremonys[i];
    option = new Option(ceremony.name);
    this._gui.ceremony.options[this._gui.ceremony.options.length] = option;
    if (option.text == this._search.ceremony) {
      this._gui.ceremony.selectedIndex = this._gui.ceremony.options.length - 1;
    }
  }
  this._gui.ceremony.onchange = function() { _self._search.ceremony = ((this.options[this.selectedIndex].text != 'All') ? this.options[this.selectedIndex].text : ''); };
  
  this._gui.reception.options[this._gui.reception.options.length] = new Option('All');
  for (var i = 0, il = this._receptions.length; i < il; i++) {
    var reception = this._receptions[i];
    option = new Option(reception.name);
    this._gui.reception.options[this._gui.reception.options.length] = option;
    if (option.text == this._search.reception) {
      this._gui.reception.selectedIndex = this._gui.reception.options.length - 1;
    }
  }
  this._gui.reception.onchange = function() { _self._search.reception = ((this.options[this.selectedIndex].text != 'All') ? this.options[this.selectedIndex].text : ''); };
  
  this._gui.weddingcolor.options[this._gui.weddingcolor.options.length] = new Option('All');
  for (var i = 0, il = this._colors.length; i < il; i++) {
    var color = this._colors[i];
    option = new Option(color.name);
    this._gui.weddingcolor.options[this._gui.weddingcolor.options.length] = option;
    if (option.text == this._search.wedding_color) {
      this._gui.weddingcolor.selectedIndex = this._gui.weddingcolor.options.length - 1;
    }
  }
  this._gui.weddingcolor.onchange = function() { _self._search.wedding_color = ((this.options[this.selectedIndex].text != 'All') ? this.options[this.selectedIndex].text : ''); };
  
  this._gui.weddingDateFrom.value = (this._search.weddingDateFrom) ? SimpleDate.format(this._search.weddingDateFrom) : '';
  this._gui.weddingDateFrom.onclick = function() { var context = this;
                                                    _self._changeDate.call(_self, this, _self._search.weddingDateFrom, function(sd) { _self._search.weddingDateFrom = sd; context.focus(); }, false);
                                                    return false;
                                                  };
  this._gui.weddingDateFrom.onkeypress = function(e) { var code = DOMUtils.getEventCode(e);
                                                        if (code == 13) {
                                                          _self._callbackFunc(_self._search);
                                                        }
                                                      };
  this._gui.weddingDateTo.value = (this._search.weddingDateTo) ? SimpleDate.format(this._search.weddingDateTo) : '';
  this._gui.weddingDateTo.onclick = function() { var context = this;
                                                  _self._changeDate.call(_self, this, _self._search.weddingDateTo, function(sd) { _self._search.weddingDateTo = sd; context.focus(); }, false);
                                                  return false;
                                                };
  this._gui.weddingDateTo.onkeypress = function(e) { var code = DOMUtils.getEventCode(e);
                                                      if (code == 13) {
                                                        _self._callbackFunc(_self._search);
                                                      }
                                                    };
  
  this._gui.sentDateFrom.value = (this._search.sentDateFrom) ? SimpleDate.format(this._search.sentDateFrom) : '';
  this._gui.sentDateFrom.onclick = function() { var context = this;
                                                    _self._changeDate.call(_self, this, _self._search.sentDateFrom, function(sd) { _self._search.sentDateFrom = sd; context.focus(); }, false);
                                                    return false;
                                                  };
  this._gui.sentDateFrom.onkeypress = function(e) { var code = DOMUtils.getEventCode(e);
                                                        if (code == 13) {
                                                          _self._callbackFunc(_self._search);
                                                        }
                                                      };
  this._gui.sentDateTo.value = (this._search.sentDateTo) ? SimpleDate.format(this._search.sentDateTo) : '';
  this._gui.sentDateTo.onclick = function() { var context = this;
                                                  _self._changeDate.call(_self, this, _self._search.sentDateTo, function(sd) { _self._search.sentDateTo = sd; context.focus(); }, false);
                                                  return false;
                                                };
  this._gui.sentDateTo.onkeypress = function(e) { var code = DOMUtils.getEventCode(e);
                                                      if (code == 13) {
                                                        _self._callbackFunc(_self._search);
                                                      }
                                                    };
  
  this._gui.receivedDateFrom.value = (this._search.receivedDateFrom) ? SimpleDate.format(this._search.receivedDateFrom) : '';
  this._gui.receivedDateFrom.onclick = function() { var context = this;
                                                     _self._changeDate.call(_self, this, _self._search.receivedDateFrom, function(sd) { _self._search.receivedDateFrom = sd; context.focus(); }, false);
                                                     return false;
                                                   };
  this._gui.receivedDateFrom.onkeypress = function(e) { var code = DOMUtils.getEventCode(e);
                                                         if (code == 13) {
                                                           _self._callbackFunc(_self._search);
                                                         }
                                                       };
  this._gui.receivedDateTo.value = (this._search.receivedDateTo) ? SimpleDate.format(this._search.receivedDateTo) : '';
  this._gui.receivedDateTo.onclick = function() { var context = this;
                                                 _self._changeDate.call(_self, this, _self._search.receivedDateTo, function(sd) { _self._search.receivedDateTo = sd; context.focus(); }, false);
                                                 return false;
                                               };
  this._gui.receivedDateTo.onkeypress = function(e) { var code = DOMUtils.getEventCode(e);
                                                     if (code == 13) {
                                                       _self._callbackFunc(_self._search);
                                                     }
                                                   };
  
  this._gui.retouchedDateFrom.value = (this._search.retouchedDateFrom) ? SimpleDate.format(this._search.retouchedDateFrom) : '';
  this._gui.retouchedDateFrom.onclick = function() { var context = this;
                                                    _self._changeDate.call(_self, this, _self._search.retouchedDateFrom, function(sd) { _self._search.retouchedDateFrom = sd; context.focus(); }, false);
                                                    return false;
                                                  };
  this._gui.retouchedDateFrom.onkeypress = function(e) { var code = DOMUtils.getEventCode(e);
                                                        if (code == 13) {
                                                          _self._callbackFunc(_self._search);
                                                        }
                                                      };
  this._gui.retouchedDateTo.value = (this._search.retouchedDateTo) ? SimpleDate.format(this._search.retouchedDateTo) : '';
  this._gui.retouchedDateTo.onclick = function() { var context = this;
                                                  _self._changeDate.call(_self, this, _self._search.retouchedDateTo, function(sd) { _self._search.retouchedDateTo = sd; context.focus(); }, false);
                                                  return false;
                                                };
  this._gui.retouchedDateTo.onkeypress = function(e) { var code = DOMUtils.getEventCode(e);
                                                      if (code == 13) {
                                                        _self._callbackFunc(_self._search);
                                                      }
                                                    };
                                                    
  
  this._gui.publishedDateFrom.value = (this._search.publishedDateFrom) ? SimpleDate.format(this._search.publishedDateFrom) : '';
  this._gui.publishedDateFrom.onclick = function() { var context = this;
                                                      _self._changeDate.call(_self, this, _self._search.publishedDateFrom, function(sd) { _self._search.publishedDateFrom = sd; context.focus(); }, false);
                                                      return false;
                                                    };
  this._gui.publishedDateFrom.onkeypress = function(e) { var code = DOMUtils.getEventCode(e);
                                                          if (code == 13) {
                                                            _self._callbackFunc(_self._search);
                                                          }
                                                        };
  this._gui.publishedDateTo.value = (this._search.publishedDateTo) ? SimpleDate.format(this._search.publishedDateTo) : '';
  this._gui.publishedDateTo.onclick = function() { var context = this;
                                                    _self._changeDate.call(_self, this, _self._search.publishedDateTo, function(sd) { _self._search.publishedDateTo = sd; context.focus(); }, false);
                                                    return false;
                                                  };
  this._gui.publishedDateTo.onkeypress = function(e) { var code = DOMUtils.getEventCode(e);
                                                        if (code == 13) {
                                                          _self._callbackFunc(_self._search);
                                                        }
                                                      };
  
  this._gui.signed.checked = this._search.signed;
  this._gui.signed.onchange = function() { if (this.checked) {
                                               _self._search.signed = true;
                                             } else {
                                               _self._search.signed = false;
                                             }
                                           };
  this._gui.nosigned.checked = this._search.nosigned;
  this._gui.nosigned.onchange = function() { if (this.checked) {
                                                _self._search.nosigned = true;
                                              } else {
                                                _self._search.nosigned = false;
                                              }
                                            };
  
  this._gui.backup.checked = this._search.backup;
  this._gui.backup.onchange = function() { if (this.checked) {
                                             _self._search.backup = true;
                                           } else {
                                             _self._search.backup = false;
                                           }
                                         };
  this._gui.nobackup.checked = this._search.nobackup;
  this._gui.nobackup.onchange = function() { if (this.checked) {
                                                _self._search.nobackup = true;
                                              } else {
                                                _self._search.nobackup = false;
                                              }
                                            };
  
  this._gui.chosen.checked = this._search.chosen;
  this._gui.chosen.onchange = function() { if (this.checked) {
                                             _self._search.chosen = true;
                                           } else {
                                             _self._search.chosen = false;
                                           }
                                         };
  this._gui.nochosen.checked = this._search.nochosen;
  this._gui.nochosen.onchange = function() { if (this.checked) {
                                                _self._search.nochosen = true;
                                              } else {
                                                _self._search.nochosen = false;
                                              }
                                            };
  
  this._gui.asstretouch.checked = this._search.asstretouch;
  this._gui.asstretouch.onchange = function() { if (this.checked) {
                                                   _self._search.asstretouch = true;
                                                 } else {
                                                   _self._search.asstretouch = false;
                                                 }
                                               };
  this._gui.noasstretouch.checked = this._search.noasstretouch;
  this._gui.noasstretouch.onchange = function() { if (this.checked) {
                                                     _self._search.noasstretouch = true;
                                                   } else {
                                                     _self._search.noasstretouch = false;
                                                   }
                                                };
    
  this._gui.check.checked = this._search.check;
  this._gui.check.onchange = function() { if (this.checked) {
                                            _self._search.check = true;
                                          } else {
                                            _self._search.check = false;
                                          }
                                        };
  this._gui.nocheck.checked = this._search.nocheck;
  this._gui.nocheck.onchange = function() { if (this.checked) {
                                              _self._search.nocheck = true;
                                            } else {
                                              _self._search.nocheck = false;
                                            }
                                          };
  
  this._gui.adminretouch.checked = this._search.adminretouch;
  this._gui.adminretouch.onchange = function() { if (this.checked) {
                                                    _self._search.adminretouch = true;
                                                  } else {
                                                    _self._search.adminretouch = false;
                                                  }
                                                };
  this._gui.noadminretouch.checked = this._search.noadminretouch;
  this._gui.noadminretouch.onchange = function() { if (this.checked) {
                                                      _self._search.noadminretouch = true;
                                                    } else {
                                                      _self._search.noadminretouch = false;
                                                    }
                                                  };
  
  this._gui.desarrange.checked = this._search.desarrange;
  this._gui.desarrange.onchange = function() { if (this.checked) {
                                                    _self._search.desarrange = true;
                                                  } else {
                                                    _self._search.desarrange = false;
                                                  }
                                                };
  this._gui.nodesarrange.checked = this._search.nodesarrange;
  this._gui.nodesarrange.onchange = function() { if (this.checked) {
                                                  _self._search.nodesarrange = true;
                                                } else {
                                                  _self._search.nodesarrange = false;
                                                }
                                              };
  
  this._gui.desretouch.checked = this._search.desretouch;
  this._gui.desretouch.onchange = function() { if (this.checked) {
                                                    _self._search.desretouch = true;
                                                  } else {
                                                    _self._search.desretouch = false;
                                                  }
                                                };
  this._gui.nodesretouch.checked = this._search.nodesretouch;
  this._gui.nodesretouch.onchange = function() { if (this.checked) {
                                                  _self._search.nodesretouch = true;
                                                } else {
                                                  _self._search.nodesretouch = false;
                                                }
                                              };
  
  this._gui.sort.checked = this._search.sort;
  this._gui.sort.onchange = function() { if (this.checked) {
                                                _self._search.sort = true;
                                              } else {
                                                _self._search.sort = false;
                                              }
                                            };
  this._gui.nosort.checked = this._search.nosort;
  this._gui.nosort.onchange = function() { if (this.checked) {
                                                   _self._search.nosort = true;
                                                 } else {
                                                   _self._search.nosort = false;
                                                 }
                                               };
  
  this._gui.author.checked = this._search.author;
  this._gui.author.onchange = function() { if (this.checked) {
                                               _self._search.author = true;
                                             } else {
                                               _self._search.author = false;
                                             }
                                           };
 this._gui.noauthor.checked = this._search.noauthor;
 this._gui.noauthor.onchange = function() { if (this.checked) {
                                                  _self._search.noauthor = true;
                                                } else {
                                                  _self._search.noauthor = false;
                                                }
                                              };
  
  this._gui.rauthor.checked = this._search.rauthor;
  this._gui.rauthor.onchange = function() { if (this.checked) {
                                               _self._search.rauthor = true;
                                             } else {
                                               _self._search.rauthor = false;
                                             }
                                           };
  this._gui.norauthor.checked = this._search.norauthor;
  this._gui.norauthor.onchange = function() { if (this.checked) {
                                                  _self._search.norauthor = true;
                                                } else {
                                                  _self._search.norauthor = false;
                                                }
                                              };
                                              
  this._gui.published.checked = this._search.published;
  this._gui.published.onchange = function() { if (this.checked) {
                                               _self._search.published = true;
                                             } else {
                                               _self._search.published = false;
                                             }
                                           };
  this._gui.nopublished.checked = this._search.nopublished;
  this._gui.nopublished.onchange = function() { if (this.checked) {
                                                  _self._search.nopublished = true;
                                                } else {
                                                  _self._search.nopublished = false;
                                                }
                                              };
  this._gui.searchButton.onclick = function() { _self._callbackFunc(_self._search); };

};

HandleSheetSearch.prototype._changeDate = function(label, currentDate, onChangeFunc, showTime) {
  var _self = this;
  this._wContainer = document.createElement('div');
  this._wContainer.style.left = DOMUtils.findPos(label)[0] + 'px';
  this._wContainer.style.top = DOMUtils.findPos(label)[1] + 'px';
  this._popupBox._open(this._wContainer, { pos: DOMUtils.findPos(label) });
  
  var ds = new DateSelect(currentDate, null, { container: this._wContainer, showTime: showTime });
  ds._selectFunc = function(sd) { _self._selectDate.call(_self, sd, label, onChangeFunc, showTime); };
};

HandleSheetSearch.prototype._selectDate = function(sd, label, onChangeFunc, showTime) {
  
  onChangeFunc(sd);
  this._showDate(sd, label, showTime);
  this._popupBox._close();
};

HandleSheetSearch.prototype._showDate = function(sd, label, showTime) {
  if (sd) { 
    label.value = SimpleDate.format(sd, showTime);
  } else {
    label.value = '';
  }
};

HandleSheetSearch.toSql = function(search) {
  var str0 = (search.customerNo != '') ? '(t.customer_id =' + search.customerNo + ')'  : '1 = 1';
  var str00 = (search.customerName != '') ? '((t.bride_name LIKE \'%' + search.customerName + '%\') OR (t.groom_name LIKE \'%' + search.customerName + '%\'))' : '1 = 1';
  var str1 = (search.branch != '') ? '(t.branch =\'' + search.branch + '\')'  : '1 = 1';
  var str2 = (search.photographer != '') ? '(t1.name = \'' + search.photographer + '\' OR t5.name = \'' + search.photographer + '\')' : '1=1';
  var str3 = (search.culture != '') ? '(t.culture1 = \'' + search.culture + '\' OR t.culture2 = \'' + search.culture + '\')' : '1=1';
  var str4 = (search.reception != '') ? '(t.reception = \'' + search.reception + '\')' : '1=1';
  var str5 = (search.ceremony != '') ? '(t.ceremony = \'' + search.ceremony + '\')' : '1=1';
  var str6 = (search.wedding_color != '') ? '(t.wedding_color = \'' + search.wedding_color + '\')' : '1=1';

  var str7 = (search.weddingDateFrom) ? '(t.wedding_date >= \'' + SimpleDate.toStamp(search.weddingDateFrom) + '\')' : '1=1';
  var str8 = (search.weddingDateTo) ? '(t.wedding_date <= \'' + SimpleDate.toStamp(search.weddingDateTo) + '\')' : '1=1';
  var str70 = (search.sentDateFrom) ? '(t.sent_date >= \'' + SimpleDate.toStamp(search.sentDateFrom) + '\')' : '1=1';
  var str80 = (search.sentDateTo) ? '(t.sent_date <= \'' + SimpleDate.toStamp(search.sentDateTo) + '\')' : '1=1';
  var str9 = (search.receivedDateFrom) ? '(t.received_date >= \'' + SimpleDate.toStamp(search.receivedDateFrom) + '\')' : '1=1';
  var str10 = (search.receivedDateTo) ? '(t.received_date <= \'' + SimpleDate.toStamp(search.receivedDateTo) + '\')' : '1=1';
  var str11 = (search.retouchedDateFrom) ? '(t.retouched_date >= \'' + SimpleDate.toStamp(search.retouchedDateFrom) + '\')' : '1=1';
  var str12 = (search.retouchedDateTo) ? '(t.retouched_date <= \'' + SimpleDate.toStamp(search.retouchedDateTo) + '\')' : '1=1';
  var str13 = (search.publishedDateFrom) ? '(t.published_date >= \'' + SimpleDate.toStamp(search.publishedDateFrom) + '\')' : '1=1';
  var str14 = (search.publishedDateTo) ? '(t.published_date <= \'' + SimpleDate.toStamp(search.publishedDateTo) + '\')' : '1=1';
  
  var str15 = '';
  if (str15 != '') {
    if (search.signed) {
      str15 += ' OR ' +  '(t.is_signed = 1)';
    }
  } else {
    if (search.signed) {
      str15 +=  '(t.is_signed = 1)';
    }
  }
  
  if (str15 != '') {
    if (search.nosigned) {
      str15 += ' OR ' +  '(t.is_signed = 0)';
    }
  } else {
    if (search.nosigned) {
      str15 +=  '(t.is_signed = 0)';
    }
  }

  var str16 = '';
  if (str16 != '') {
    if (search.backup) {
      str16 += ' OR ' +  '(t.is_asst_backup = 1)';
    }
  } else {
    if (search.backup) {
      str16 +=  '(t.is_asst_backup = 1)';
    }
  }
  
  if (str16 != '') {
    if (search.nobackup) {
      str16 += ' OR ' +  '(t.is_asst_backup = 0)';
    }
  } else {
    if (search.nobackup) {
      str16 +=  '(t.is_asst_backup = 0)';
    }
  }
  
  var str17 = '';
  if (str17 != '') {
    if (search.chosen) {
      str17 += ' OR ' +  '(t.is_asst_pickup = 1)';
    }
  } else {
    if (search.chosen) {
      str17 +=  '(t.is_asst_pickup = 1)';
    }
  }
  
  if (str17 != '') {
    if (search.nochosen) {
      str17 += ' OR ' +  '(t.is_asst_pickup = 0)';
    }
  } else {
    if (search.nochosen) {
      str17 +=  '(t.is_asst_pickup = 0)';
    }
  }
  
  var str18 = '';
  if (str18 != '') {
    if (search.asstretouch) {
      str18 += ' OR ' +  '(t.is_asst_retouched = 1)';
    }
  } else {
    if (search.asstretouch) {
      str18 +=  '(t.is_asst_retouched = 1)';
    }
  }
  
  if (str18 != '') {
    if (search.noasstretouch) {
      str18 += ' OR ' +  '(t.is_asst_retouched = 0)';
    }
  } else {
    if (search.noasstretouch) {
      str18 +=  '(t.is_asst_retouched = 0)';
    }
  }
  
  var str19 = '';
  if (str19 != '') {
    if (search.check) {
      str19 += ' OR ' +  '(t.is_admin_checked = 1)';
    }
  } else {
    if (search.check) {
      str19 +=  '(t.is_admin_checked = 1)';
    }
  }
  
  if (str19 != '') {
    if (search.nocheck) {
      str19 += ' OR ' +  '(t.is_admin_checked = 0)';
    }
  } else {
    if (search.nocheck) {
      str19 +=  '(t.is_admin_checked = 0)';
    }
  }
  
  var str20 = '';
  if (str20 != '') {
    if (search.adminretouch) {
      str20 += ' OR ' +  '(t.is_admin_retouched = 1)';
    }
  } else {
    if (search.adminretouch) {
      str20 +=  '(t.is_admin_retouched = 1)';
    }
  }
  
  if (str20 != '') {
    if (search.noadminretouch) {
      str20 += ' OR ' +  '(t.is_admin_retouched = 0)';
    }
  } else {
    if (search.noadminretouch) {
      str20 +=  '(t.is_admin_retouched = 0)';
    }
  }
  
  var str21 = '';
  if (str21 != '') {
    if (search.desarrange) {
      str21 += ' OR ' +  '(t.is_choose_designer = 1)';
    }
  } else {
    if (search.desarrange) {
      str21 +=  '(t.is_choose_designer = 1)';
    }
  }
  
  if (str21 != '') {
    if (search.nodesarrange) {
      str21 += ' OR ' +  '(t.is_choose_designer = 0)';
    }
  } else {
    if (search.nodesarrange) {
      str21 +=  '(t.is_choose_designer = 0)';
    }
  }
  
  var str211 = '';
  if (str211 != '') {
    if (search.desretouch) {
      str211 += ' OR ' +  '(t.is_des_retouched = 1)';
    }
  } else {
    if (search.desretouch) {
      str211 +=  '(t.is_des_retouched = 1)';
    }
  }
  
  if (str211 != '') {
    if (search.nodesretouch) {
      str211 += ' OR ' +  '(t.is_des_retouched = 0)';
    }
  } else {
    if (search.nodesretouch) {
      str211 +=  '(t.is_des_retouched = 0)';
    }
  }
  
  var str22 = '';
  if (str22 != '') {
    if (search.sort) {
      str22 += ' OR ' +  '(t.is_admin_sorted = 1)';
    }
  } else {
    if (search.sort) {
      str22 +=  '(t.is_admin_sorted = 1)';
    }
  }
  
  if (str22 != '') {
    if (search.nosort) {
      str22 += ' OR ' +  '(t.is_admin_sorted = 0)';
    }
  } else {
    if (search.nosort) {
      str22 +=  '(t.is_admin_sorted = 0)';
    }
  }
  
  var str23 = '';
  if (str23 != '') {
    if (search.author) {
      str23 += ' OR ' +  '(t.is_asst_arranged = 1)';
    }
  } else {
    if (search.author) {
      str23 +=  '(t.is_asst_arranged = 1)';
    }
  }
  
  if (str23 != '') {
    if (search.noauthor) {
      str23 += ' OR ' +  '(t.is_asst_arranged = 0)';
    }
  } else {
    if (search.noauthor) {
      str23 +=  '(t.is_asst_arranged = 0)';
    }
  }
  
  var str24 = '';
  if (str24 != '') {
    if (search.rauthor) {
      str24 += ' OR ' +  '(t.is_asst_received = 1)';
    }
  } else {
    if (search.rauthor) {
      str24 +=  '(t.is_asst_received = 1)';
    }
  }
  
  if (str24 != '') {
    if (search.norauthor) {
      str24 += ' OR ' +  '(t.is_asst_received = 0)';
    }
  } else {
    if (search.norauthor) {
      str24 +=  '(t.is_asst_received = 0)';
    }
  }
  
  var str25 = '';
  if (str25 != '') {
    if (search.published) {
      str25 += ' OR ' +  '(t.is_asst_published = 1)';
    }
  } else {
    if (search.published) {
      str25 +=  '(t.is_asst_published = 1)';
    }
  }
  
  if (str25 != '') {
    if (search.nopublished) {
      str25 += ' OR ' +  '(t.is_asst_published = 0)';
    }
  } else {
    if (search.nopublished) {
      str25 +=  '(t.is_asst_published = 0)';
    }
  }
  
  return '(' + '(' + escape(str0) + ')' + ' AND ' + '(' + str00 + ')' + ' AND ' + '(' + str1 + ')' + ' AND ' + '(' + str2 + ')' + ' AND ' + '(' + str3 + ')' + ' AND ' + '(' + str4 + ')' + ' AND ' + '(' + str5 + ')' + ' AND ' + '(' + str6 + ')' + ' AND ' + '(' + str7 + ')'
             + ' AND ' + '(' + str8 + ')' + ' AND ' + '(' + str70 + ')' + ' AND ' + '(' + str80 + ')' + ' AND ' + '(' + str9 + ')' + ' AND ' + '(' + str10 + ')' + ' AND ' + '(' + str11 + ')' + ' AND ' + '(' + str12 + ')' + ' AND ' + '(' + str13 + ')'
             + ' AND ' + '(' + str14 + ')' + ' AND ' + '(' + ((str15 != '') ? str15 : '1=1') + ')' + ' AND ' + '(' + ((str16 != '') ? str16 : '1=1') + ')' + ' AND ' + '(' + ((str17 != '') ? str17 : '1=1') + ')' 
             + ' AND ' + '(' + ((str18 != '') ? str18 : '1=1') + ')' + ' AND ' + '(' + ((str19 != '') ? str19 : '1=1') + ')' + ' AND ' + '(' + ((str20 != '') ? str20 : '1=1') + ')' + ' AND ' +  '(' + ((str21 != '') ? str21 : '1=1') + ')'
             + ' AND ' + '(' + ((str211 != '') ? str211 : '1=1') + ')' + ' AND ' + '(' + ((str22 != '') ? str22 : '1=1') + ')' + ' AND ' + '(' + ((str23 != '') ? str23 : '1=1') + ')' + ' AND ' + '(' + ((str24 != '') ? str24 : '1=1') + ')' + ' AND ' +  '(' + ((str25 != '') ? str25 : '1=1') + '))';
};